﻿using NetServer;
using System.Net;

namespace DeviceController.NetCoreServer.Services
{
    public class DeviceControllerServer : TcpServer
    {
        public event EventHandler<TcpSession>? Connected;

        public event EventHandler<TcpSession>? Disconnected;

        public DeviceControllerServer(IPAddress address, int port) : base(address, port)
        {
        }

        protected override TcpSession CreateSession()
        {
            return new DeviceControllerSession(this);
        }

        protected override void OnConnected(TcpSession session)
        {
            Connected?.Invoke(this, session);
        }

        protected override void OnDisconnected(TcpSession session)
        {
            Disconnected?.Invoke(this, session);
        }
    }
}
